<template>
  <div class="editform">
    <!-- 基本信息 -->
    <div class="duty">基本信息</div>
    <div class="clearfix">
      <div class="FormPanelDiv" :style="{width:imgUrl!==''?'calc(100% - 130px)':'99%',}">
        <FormPanel
          ref="FormPanel"
          :list="formList"
          :cols="3"
          labelWidth="140"
          :formType="formType"
          :isSubmitBtn="false"
        />
      </div>
      <!-- <div class="imgDiv">
        <img :src="imgUrl" alt />
      </div>-->
    </div>
    <!-- <div v-show="this.dataType == 10461001">
      <div class="duty">认证信息</div>
      <FilterTable
        ref="table"
        :columns="columns"
        :fetchapi="fetchApi"
        :params="fetchParams"
        :isSelectColumn="false"
        :isToperInfo="false"
        :datakey="'records'"
        :onColumnsChange="columns => this.columns = columns"
      ></FilterTable>
    </div>-->
    <!-- 技能信息 -->
    <div
      class="duty"
      v-show="this.dataType == 10461001?this.afterSale == 10041001?true:false:false"
    >技能信息</div>
    <div class="FormPanelDiv clearfix">
      <FormPanel
        :formType="formType"
        v-if="this.dataType == 10461001?this.afterSale == 10041001?true:false:false"
        ref="FormPanel1"
        :list="formList1"
        labelWidth="130"
        :cols="3"
        :isSubmitBtn="false"
      />
      <div class="editformBtn">
        <el-button @click="closeDialog">返 回</el-button>
        <el-button v-show="this.formType=='show'?false:true" @click="saveDialog" type="primary">保存</el-button>
      </div>
    </div>
    <!--isShowIDCade  -->
    <BaseDialog
      :visible.sync="isShowIDCade"
      title
      destroyOnClose
      width="80%"
      :containerStyle="{height: 'calc(100% - 20px)', overflow: 'auto', paddingBottom: '10px'}"
    >
      <div style="line-height:40px;">
        身份证号当前已绑定员工编号：
        <span style="color:#ccc;">{{this.userNum}}</span>
      </div>
      <p style="line-height:40px;">当前账号绑定信息：</p>
      <FormPanel
        ref="FormPanel2"
        :list="formList2"
        labelWidth="130"
        :cols="3"
        formType="show"
        :isSubmitBtn="false"
      />
      <div style="text-align: center;margin-top: 30px;">
        <el-button
          style="width: 9vw;"
          @click="closeDialog2"
        >取&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;消</el-button>
        <el-button style="width: 9vw;" @click="exportUserinfo" type="primary">导入原账号信息</el-button>
      </div>
    </BaseDialog>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { getJsonTree } from '@/utils/index';
import { getUserInfoList } from '@/api/common/auth/userInfo/index.js';
import { getComOrgTreeList, getPresetRole, getComOrgTreeListDistinct } from '@/api/common/org/employeeInfo';
import { getEmployeeInfo, postEmployeeInfo } from '@/api/common/auth/employeeAuth';
import { dealerAuthenticationList } from '@/api/cms-api/origin/personnelInfo/areaMaintain';
import { IDNumber, phone, numberCheck, email } from '@/utils/validate';
import { formatdateByDay } from '@/utils/index.js';
export default {
  name: 'editform',
  mixins: [dictionary],
  props: ['rowData', 'type', 'workGroupsData', 'maintainWorkData', 'afterSale', 'dataType'],
  data() {
    return {
      formList: this.createFormList(),
      formList1: this.createFormList1(),
      formList2: this.createFormList2(),
      columns: this.createTableColumns(),
      imgUrl: '',
      fetchApi: dealerAuthenticationList,
      fetchParams: { empNo: this.rowData.employeeNo },
      isShow: false,
      formType: 'edit',
      forEach: {},
      userNum: '123456',
      isShowIDCade: false,
      employeeStatus:'',
      lockFlag:''
    };
  },

  methods: {
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 200,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '认证类型',
          dataIndex: 'authenticationName',
          width: 200,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '认证日期',
          dataIndex: 'authenticationDate',
          width: 200,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{formatdateByDay(props.row.authenticationDate)} </span>;
          }
          // align:"center"
        },
        {
          title: '认证状态',
          width: 200,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>已认证</span>;
          }
          // align:"center"
        },
        {
          title: '认证级别',
          dataIndex: 'authenticationLevel',
          width: 200,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        }
      ];
    },
    async authentication(param) {
      let resl = await dealerAuthenticationList(param);
      console.log('232323232323-----------', resl);
    },
    createFormList() {
      return [
        // {
        //   type: 'DATE',
        //   label: '入职日期',
        //   fieldName: 'entryTime',
        //   placeholder: '',
        //   initialValue: '',
        //   //于2019-12-17 修改 日期去掉时分秒（勿删）-START
        //   disabled: true,
        //   format: 'yyyy-MM-dd'
        //   //于2019-12-17 修改 日期去掉时分秒（勿删）-START
        //   //rules: [{ required: true, message: '请选择日期', trigger: 'blur' }]
        // },
        {
          type: 'INPUT',
          label: '员工编号',
          fieldName: 'employeeNo',
          placeholder: '',
          initialValue: '',
          hidden:true,
          disabled: true
          // rules: [{ required: true, message: '请输入员工编号', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '登录账号',
          fieldName: 'userCode',
          placeholder: '',
          initialValue: '',
          disabled: true,
          // rules: [{ required: true, message: '请输入登录账号', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '员工姓名',
          fieldName: 'employeeName',
          placeholder: '',
          initialValue: '',
          disabled: true,
          //长春CMS
          // rules: [{ required: true, message: '请输入员工姓名', trigger: 'blur' }, { min: 0, max: 30, message: '长度在 0 到 30 个字符', trigger: 'blur' }]
          //长春CMS
        },
        {
          type: 'INPUT',
          label: '手机号码',
          fieldName: 'mobilePhone',
          placeholder: '',
          initialValue: '',
          disabled: false,
          rules: [{ required: true, message: '请输入手机号码', trigger: 'blur' }, { trigger: 'blur', validator: phone }]
        },
        {
          type: 'SELECT',
          label: '性别',
          fieldName: 'gender',
          placeholder: '',
          initialValue: '',
          disabled: false,
          itemList: this.createDictList('1002')
          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT_TREE',
          label: '所属部门',
          fieldName: 'orgId',
          placeholder: '所属部门',
          initialValue: '',
          selfCols: 2,
          itemList: [],
          disabled: false,
          rules: [{ required: true, message: '请选择所属部门', trigger: 'change' }]
        },
        // {
        //   type: 'SELECT',
        //   label: '在职状态',
        //   fieldName: 'employeeStatus',
        //   placeholder: '',
        //   initialValue: '',
        //   hidden: true,
        //   itemList: this.createDictList('1008'),
        //   // change: val => {
        //   //   if (val == 10081002) {
        //   //     this.formList[5].disabled = false;
        //   //   } else {
        //   //     this.formList[5].disabled = true;
        //   //   }
        //   // },
        //   // rules: [{ required: true, message: '请选择在职状态', trigger: 'blur' }]
        // },
        // {
        //   type: 'DATE',
        //   label: '离职日期',
        //   fieldName: 'dimissionDate',
        //   placeholder: '',
        //   initialValue: '',
        //   //于2019-12-17 修改 日期去掉时分秒（勿删）-START
        //   disabled: true,
        //   format: 'yyyy-MM-dd'
        //   //于2019-12-17 修改 日期去掉时分秒（勿删）-END
        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        // {
        //   type: 'SELECT',
        //   label: '培训第一岗位',
        //   fieldName: 'firstPost',
        //   placeholder: '',
        //   initialValue: '',
        //   itemList: this.createDictList('2588'),
        //   //长春CMS
        //   rules: [],
        //   //长春CMS
        //   disabled: false,
        //   hidden: false
        //   // rules: [{ required: true, message: '请选择在职状态', trigger: 'blur' }]
        // },
        // {
        //   type: 'SELECT',
        //   label: '培训第二岗位',
        //   fieldName: 'secondPost',
        //   placeholder: '',
        //   initialValue: '',
        //   itemList: this.createDictList('2588'),
        //   disabled: false,
        //   hidden: false
        //   // rules: [{ required: true, message: '请选择在职状态', trigger: 'blur' }]
        // },
        // {
        //   type: 'SELECT',
        //   label: '培训第三岗位',
        //   fieldName: 'thirdPost',
        //   placeholder: '',
        //   initialValue: '',
        //   itemList: this.createDictList('2588'),
        //   disabled: false,
        //   hidden: false
        //   // rules: [{ required: true, message: '请选择在职状态', trigger: 'blur' }]
        // },


        // {
        //   type: 'INPUT',
        //   label: '身份证号',
        //   fieldName: 'certificateId',
        //   placeholder: '',
        //   initialValue: '',
        //   disabled: true,
        //   rules: []
        //   // change:val=>{
        //   //   console.log(val,"123")
        //   //   if(val){
        //   //     this.formList.find(item=>item.fieldName == "certificateId").rules=[{ required: true,  trigger: 'blur' ,validator: IDNumber}]
        //   //     if(val.length === 18){
        //   //       this.testIDNumber(val)
        //   //     }
        //   //   }else{
        //   //     this.formList.find(item=>item.fieldName == "certificateId").rules=[{ required: false,message: '', trigger: 'blur'}]
        //   //   }
        //   // }
        // },
        // {
        //   type: 'DATE',
        //   label: '出生日期',
        //   fieldName: 'birthday',
        //   placeholder: '',
        //   initialValue: '',
        //   //于2019-12-17 修改 日期去掉时分秒（勿删）-START
        //   format: 'yyyy-MM-dd',
        //   disabled: true
        //   // rules: [{ required: true, message: '请选择出生日期', trigger: 'blur' }],
        //   //于2019-12-17 修改 日期去掉时分秒（勿删）-END
        // },
        // {
        //   type: 'INPUT',
        //   label: 'Email',
        //   fieldName: 'eMail',
        //   placeholder: '',
        //   initialValue: '',
        //   disabled: false,
        //   rules: [{ required: true, message: '请输入eMail', trigger: 'blur', validator: email }]
        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        // {
        //   type: 'INPUT',
        //   label: '民族',
        //   fieldName: 'nation',
        //   placeholder: '',
        //   initialValue: '',
        //   maxlength: 16,
        //   disabled: false
        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        // {
        //   type: 'SELECT',
        //   label: '驾驶证级别',
        //   fieldName: 'drivingLevel',
        //   placeholder: '',
        //   initialValue: '',
        //   disabled: false,
        //   itemList: [{ text: 'A', value: 'A' }, { text: 'B', value: 'B' }, { text: 'C', value: 'C' }]
        //   // rules: [{ required: true, message: '请选择是否冻结', trigger: 'blur' }]
        // },
        // {
        //   type: 'SELECT',
        //   label: '教育程度',
        //   fieldName: 'degreeEdu',
        //   placeholder: '',
        //   disabled: false,
        //   initialValue: '',
        //   rules: [{ required: true, message: '请选择教育程度', trigger: 'blur' }],
        //   itemList: this.createDictList('1035')
        //   // rules: [{ required: true, message: '请选择是否冻结', trigger: 'blur' }]
        // },
        // {
        //   type: 'INPUT',
        //   label: '年龄',
        //   fieldName: 'age',
        //   placeholder: '',
        //   initialValue: '',
        //   maxlength: 3,
        //   disabled: false,
        //   rules: [{ required: false, message: '请输入3位数字', trigger: 'blur', validator: numberCheck }]
        // },
        // {
        //   type: 'INPUT',
        //   label: '汽车行业时长（年）',
        //   fieldName: 'autoTime',
        //   placeholder: '',
        //   initialValue: '',
        //   maxlength: 3,
        //   disabled: false,
        //   rules: [{ required: true, message: '请输入汽车行业时长', trigger: 'blur', validator: numberCheck }]
        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        // {
        //   type: 'SELECT',
        //   label: '是否校企合作院校毕业',
        //   fieldName: 'cooperationSchool',
        //   placeholder: '',
        //   itemList: this.createDictList('1004'),
        //   initialValue: '',
        //   rules: [{ required: true, message: '请选择是否校企合作院校毕业', trigger: 'blur' }],
        //   disabled: false
        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        // {
        //   type: 'INPUT',
        //   label: '毕业院校',
        //   fieldName: 'graduateSchool',
        //   placeholder: '',
        //   initialValue: '',
        //   disabled: false,
        //   rules: [{ required: true, message: '请填写毕业院校', trigger: 'blur' }],
        //   maxlength: 16
        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // },
        // {
        //   type: 'SELECT',
        //   label: '是否冻结',
        //   fieldName: 'lockFlag',
        //   placeholder: '',
        //   initialValue: '',
        //   hidden: true,
        //   itemList: this.createDictList('1004'),
          // change: val => {
          //   console.log(val);
          //   if (val == 10041001) {
          //     this.formList.find(item => item.fieldName == 'lockCause').disabled = false;
          //   } else {
          //     this.formList.find(item => item.fieldName == 'lockCause').disabled = true;
          //     this.formList.find(item => item.fieldName == 'lockCause').initialValue = '';
          //   }
          // },
          // rules: [{ required: true, message: '请选择是否冻结', trigger: 'blur' }]
        // },
        // {
        //   type: 'INPUT',
        //   label: '冻结原因',
        //   fieldName: 'lockCause',
        //   placeholder: '',
        //   initialValue: '',
        //   disabled: true,
        //   // itemList: this.createDictList('1004'),
        //   maxlength: 32

        //   // rules: [{ required: true, message: '请选择是否冻结', trigger: 'blur' }]
        // },
        // {
        //   type: 'TEXT_AREA',
        //   label: '备注',
        //   fieldName: 'remark',
        //   placeholder: '',
        //   initialValue: '',
        //   disabled: false,
        //   selfCols: 3,
        //   maxlength: 32
        //   // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        // }
      ];
    },
    createFormList1() {
      return [
        {
          type: 'SELECT',
          label: '班组',
          fieldName: 'workgroupId',
          placeholder: '',
          initialValue: '',
          hidden: false,
          itemList: this.createDictList('1004')
          //rules: [{ required: true, message: '请选择班组', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '工种',
          fieldName: 'workerTypeId',
          placeholder: '',
          initialValue: '',
          hidden: false,
          itemList: this.createDictList('8041')
          //rules: [{ required: true, message: '请选择工种', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '技师等级',
          fieldName: 'technicianGrade',
          placeholder: '',
          initialValue: '',
          hidden: false,
          itemList: this.createDictList('8054')
          //rules: [{ required: true, message: '请选择技师等级', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '主工位',
          fieldName: 'maintainStationId',
          placeholder: '',
          initialValue: '',
          hidden: false,
          itemList: this.createDictList('1004')
          //rules: [{ required: true, message: '请选择主工位', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '副工位',
          fieldName: 'deputyStationId',
          placeholder: '',
          initialValue: '',
          hidden: false,
          itemList: this.createDictList('1004')
          //rules: [{ required: true, message: '请选择副工位', trigger: 'blur' }]
        }
      ];
    },
    createFormList2() {
      return [
        {
          type: 'INPUT',
          label: '登录账号',
          fieldName: 'userCode',
          placeholder: '',
          initialValue: ''
          // rules: [{ required: true, message: '请输入登录账号', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '员工姓名',
          fieldName: 'employeeName',
          placeholder: '',
          initialValue: ''
          // rules: [{ required: true, message: '请输入员工姓名', trigger: 'blur' },{ min: 0, max: 6, message: '长度在 0 到 6 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '手机号码',
          fieldName: 'mobilePhone',
          placeholder: '',
          initialValue: ''
        },
        {
          type: 'SELECT',
          label: '性别',
          fieldName: 'gender',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('1002')

          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '身份证号',
          fieldName: 'certificateId',
          placeholder: '',
          initialValue: ''
        },
        {
          type: 'DATE',
          label: '出生日期',
          fieldName: 'birthday',
          placeholder: '',
          initialValue: ''

          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: 'Email',
          fieldName: 'eMail',
          placeholder: '',
          initialValue: '',
          rules: [{ required: false, message: '请输入eMail', trigger: 'blur', validator: email }]
          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '民族',
          fieldName: 'nation',
          placeholder: '',
          initialValue: ''

          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '驾驶证级别',
          fieldName: 'drivingLevel',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('1004')
          // rules: [{ required: true, message: '请选择是否冻结', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '教育程度',
          fieldName: 'degreeEdu',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('4049')
          // rules: [{ required: true, message: '请选择是否冻结', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '年龄',
          fieldName: 'age',
          placeholder: '',
          initialValue: '',
          maxlength: 3,
          rules: [{ required: false, message: '请输入3位数字', trigger: 'blur', validator: numberCheck }]
          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '汽车行业时长（年）',
          fieldName: 'autoTime',
          placeholder: '',
          initialValue: '',
          maxlength: 3,
          rules: [{ required: false, message: '请输入3位数字', trigger: 'blur', validator: numberCheck }]
          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '是否校企合作院校毕业',
          fieldName: 'cooperationSchool',
          placeholder: '',
          initialValue: ''
          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '毕业院校',
          fieldName: 'graduateSchool',
          placeholder: '',
          initialValue: '',
          maxlength: 16
          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        }
      ];
    },
    init() {
      //2019-12-17 【更改】车场端新建员工屏蔽培训第一、二、三岗位-START
      //如果是车场端新建员工屏蔽第一、二、三岗位
      if (this.dataType == 10461003) {
        // this.formList.find(item => item.fieldName === 'firstPost').hidden = true;
        // this.formList.find(item => item.fieldName === 'secondPost').hidden = true;
        // this.formList.find(item => item.fieldName === 'thirdPost').hidden = true;
      }
      //2019-12-17 【更改】车场端新建员工屏蔽培训第一、二、三岗位-END
      //第一二三岗位数据
      // getPresetRole().then(res => {
      //   // console.log(res,"第一二三岗位数据")
      //   res.data.map(x => {
      //     this.formList.find(item => item.fieldName === 'firstPost').itemList.push({ text: x.roleName, value: x.roleId });
      //     this.formList.find(item => item.fieldName === 'secondPost').itemList.push({ text: x.roleName, value: x.roleId });
      //     this.formList.find(item => item.fieldName === 'thirdPost').itemList.push({ text: x.roleName, value: x.roleId });
      //   });
      // });
      getEmployeeInfo(this.rowData.employeeNo).then(res => {
        this.formList.forEach(x => {
          x.initialValue = res.data[x.fieldName];

          // if (this.formList[4].initialValue == 10081002) {
          //   this.formList[5].disabled = false;
          // }
        });
        this.formList1.forEach(x => {
          x.initialValue = res.data[x.fieldName];
        });
        this.employeeStatus=res.data["employeeStatus"];
          this.lockFlag=res.data["lockFlag"];
      });
      if (this.type == '明细') {
        this.formType = 'show';
        this.formList.forEach(x => {
          x.rules = [];
          x.disabled = true;
        });
        this.formList1.forEach(x => {
          x.rules = [];
          x.disabled = true;
        });
      } else {
        this.formType = 'edit';
      }
      if (this.afterSale != 10041001 || this.dataType == 10461003) {
        this.formList1.find(item => item.fieldName === 'workgroupId').hidden = true;
        this.formList1.find(item => item.fieldName === 'maintainStationId').hidden = true;
        this.formList1.find(item => item.fieldName === 'deputyStationId').hidden = true;
        this.formList1.find(item => item.fieldName === 'workerTypeId').hidden = true;
        this.formList1.find(item => item.fieldName === 'technicianGrade').hidden = true;
      }
      this.formList1.find(item => item.fieldName === 'workgroupId').itemList = this.workGroupsData;
      this.formList1.find(item => item.fieldName === 'maintainStationId').itemList = this.maintainWorkData;
      this.formList1.find(item => item.fieldName === 'deputyStationId').itemList = this.maintainWorkData;
      // this.formList[10].initialValue=Date(this.rowData.birthday)
    },
    testIDNumber(val) {
      console.log(val, 'm123');
    },
    //导入原账号信息
    exportUserinfo(data) {
      let FormPanel2Data = this.$refs['FormPanel2'].SUBMIT_FORM;
      console.log(FormPanel2Data, this.userNum, 'FormPanel2Data');
      this.closeDialog2();
    },
    //返回
    closeDialog2() {
      this.isShowIDCade = false;
    },
    //原账号状态为在职，
    open() {
      this.$alert(`<p>身份证号当前已绑定员工编号：<i>${this.userNum}</i></p><p style="font-size: 12px;color: #ccc;">身份证号不能重复绑定，请更换后再试</p>`, {
        confirmButtonText: '知道了',
        dangerouslyUseHTMLString: true,
        callback: action => {}
      });
    },
    // 保存
    saveDialog() {
      let FormPanelData = this.$refs.FormPanel.SUBMIT_FORM();
      FormPanelData.employeeNo = this.rowData.employeeNo;
      FormPanelData.employeeStatus=this.employeeStatus;
      FormPanelData.lockFlag=this.lockFlag;
      //于2019-12-17 修改 日期去掉时分秒传入后台需要加上时分秒（勿删）-START
      // if (FormPanelData.dimissionDate != null || FormPanelData.dimissionDate != undefined) {
      //   FormPanelData.dimissionDate = FormPanelData.dimissionDate + ' 00:00:00';
      // }
      //于2019-12-17 修改 日期去掉时分秒传入后台需要加上时分秒（勿删）-END
      console.log(FormPanelData, 'FormPanelData');
      // || !this.formList[1].initialValue
      if (FormPanelData) {
        if (
        //  !this.formList[0].initialValue ||     //2020/1/6 修改 入职日期 不校验必填
          // !this.formList[2].initialValue ||
          !this.formList[3].initialValue ||
          !this.formList[5].initialValue ) {
          this.$message({
            message: '请填写必填项',
            type: 'warning'
          });
        } else {
          // console.log(this.formList,this.imgUrl,"formList")
          this.params = {
            ...FormPanelData,
            workgroupId: this.formList1[0].initialValue,
            workerTypeId: this.formList1[1].initialValue,
            technicianGrade: this.formList1[2].initialValue,
            maintainStationId: this.formList1[3].initialValue,
            deputyStationId: this.formList1[4].initialValue
          };
          console.log(this.params, 'this.params');
          let isTrue = true;
          // if (this.params.certificateId) {
          //   isTrue = true;
          //   this.formList.find(item => item.fieldName == 'certificateId').rules = [{ required: true, trigger: 'blur', validator: IDNumber }];
          // } else {
          //   this.formList.find(item => item.fieldName == 'certificateId').rules = [];

          //   if (!this.params.firstPost && !this.params.secondPost && !this.params.secondPost) {
          //     // console.log(isTrue,"isTrue1")
          //     isTrue = true;
          //   } else if (!this.params.firstPost && !this.params.secondPost) {
          //     // console.log(isTrue,"isTrue2")
          //     isTrue = true;
          //   } else if (!this.params.firstPost && !this.params.thirdPost) {
          //     // console.log(isTrue,"isTrue3")
          //     isTrue = true;
          //   } else if (!this.params.secondPost && !this.params.thirdPost) {
          //     // console.log(isTrue,"isTrue4")
          //     isTrue = true;
          //   } else if (this.params.firstPost == this.params.secondPost) {
          //     // console.log(isTrue,"isTrue5")
          //     isTrue = false;
          //     this.$message({
          //       message: '第一岗位、第二岗位、第三岗位所选内容不可重复',
          //       type: 'info'
          //     });
          //   } else if (this.params.firstPost == this.params.thirdPost) {
          //     // console.log(isTrue,"isTrue6")
          //     isTrue = false;
          //     this.$message({
          //       message: '第一岗位、第二岗位、第三岗位所选内容不可重复',
          //       type: 'info'
          //     });
          //   } else if (this.params.secondPost == this.params.thirdPost) {
          //     // console.log(isTrue,"isTrue7")
          //     isTrue = false;
          //     this.$message({
          //       message: '第一岗位、第二岗位、第三岗位所选内容不可重复',
          //       type: 'info'
          //     });
          //   } else {
          //     isTrue = true;
          //   }
          // }
          if (isTrue) {
            postEmployeeInfo(this.params).then(res => {
              // console.log(res,"res123")
              debugger
              if (res.resultCode == 200) {
                this.closeDialog('refresh');
                this.$message({
                  message: '保存成功',
                  type: 'success'
                });
              }else if(res.type=='3'){
                  this.$message({
                  message: res.data ,
                  type: 'warning'
                });
              }
            });
          }
        }
      }
    },
    // 返回
    closeDialog(type) {
      this.$emit('close', false, type);
    },
    // 部门树
    async inputTree() {
      const res = await getComOrgTreeListDistinct();
      var that = res.data;
      that.forEach(el => (el.text = el.text));
      that.forEach(el => (el.value = el.orgId));
      that.forEach(el => (el.parentId = el.parent));
      this.formList[5].itemList = getJsonTree(that);
      console.log(this.formList[5].itemList, 'this.formList[5].itemList');
      this.formList[5].initialValue = this.rowData.orgId;
      this.formList[5].placeholder = this.rowData.orgName;
      // console.log(this.formList[3].initialValue,this.formList[3].placeholder,"placeholder")
    }
  },
  mounted() {
    //this.authentication({ empNo: '2' });
    this.init();
    this.inputTree();
  }
};
</script>

<style lang="less" scoped>
.clearfix::after {
  content: '';
  height: 0;
  visibility: hidden;
  clear: both;
  display: block;
}
.clearfix {
  zoom: 1;
}
.editform {
  .FormPanelDiv {
    width: 99%;
    float: left;
  }
  .imgDiv {
    width: 100px;
    min-height: 150px;
    border: 1px solid #000;
    float: right;
    margin-right: 10px;
    /* position: absolute;
        right: 10%;
        top: 0; */
  }
  .editformBtn {
    text-align: center;
    margin-top: 15px;
  }
  .duty {
    width: 99%;
    height: 30px;
    line-height: 30px;
    margin-bottom: 5px;
    background: #eee;
    text-indent: 5px;
  }
}
</style>
